//
//  RegistViewController.m
//  AoJi
//
//  Created by IMacLife on 15/1/22.
//  Copyright (c) 2015年 xuanheng. All rights reserved.
//

#import "RegistViewController.h"
#import "PrivacyPolicyViewController.h"
#import "PersonalViewController.h"

#import "YHNetwork.h"
#import "NSUserDefaultsKeys.h"

#define textFieldWidth self.view.frame.size.width-26
@interface RegistViewController ()


@end

@implementation RegistViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor=[UIColor colorWithRed:236.0f/255.0f green:236.0f/255.0f blue:236.0f/255.0f alpha:1.0f];
    
    UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    titleView.backgroundColor=[UIColor colorWithRed:246.0f/255.0f green:246.0f/255.0f blue:246.0f/255.0f alpha:1.0f];
    
    UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom];
    back.frame=CGRectMake(0, 20, 44, 44);
    [back setImage:[UIImage imageNamed:@"fanhuihui"] forState:UIControlStateNormal];
    [back addTarget:self action:@selector(backLogin) forControlEvents:UIControlEventTouchUpInside];
    [titleView addSubview:back];
    
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-50, 30, 100, 30)];
    title.text=@"登录";
    title.textAlignment=NSTextAlignmentCenter;
    [titleView addSubview:title];
    
    [self.view addSubview:titleView];
    

    //文本框
//    NSArray *array=@[@"请输入用户名",@"填写手机号,其他用户不可见",@"建议数字,字母符号组合",@"请确认密码",@"请选择所在城市"];
//    for (int i=0; i < 5; i++) {
//       txtField = [[UITextField alloc]initWithFrame:CGRectMake(20, (i*50)+80, textFieldwidth, 50)];
//        txtField.borderStyle=UITextFieldViewModeAlways;
//        txtField.placeholder=array[i];
//        txtField.tag=100+i;
//        txtField.delegate=self;
//        [self.view addSubview:txtField];
//    }
    
    userField=[[UITextField alloc]initWithFrame:CGRectMake(13, 78, textFieldWidth, 44)];
    userField.placeholder=@"请输入用户名";
    userField.font=[UIFont systemFontOfSize:17];
    UIImageView *user = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yonghuming"]];
    userField.leftView=user;
    userField.leftViewMode=UITextFieldViewModeAlways;
    userField.delegate=self;
    userField.borderStyle=UITextFieldViewModeAlways;
    [self.view addSubview:userField];
    
    iphoneField=[[UITextField alloc]initWithFrame:CGRectMake(13, CGRectGetMaxY(userField.frame), textFieldWidth, 44)];
    iphoneField.placeholder=@"填写手机号,其他用户不可见";
    iphoneField.font=[UIFont systemFontOfSize:17];
    UIImageView *call = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"lianxidianhua"]];
    iphoneField.leftView=call;
    iphoneField.leftViewMode=UITextFieldViewModeAlways;
    iphoneField.delegate=self;
    //键盘为数字
    iphoneField.keyboardType=UIKeyboardTypeDecimalPad;
    iphoneField.borderStyle=UITextFieldViewModeAlways;
    [self.view addSubview:iphoneField];
    
    passField=[[UITextField alloc]initWithFrame:CGRectMake(13, CGRectGetMaxY(iphoneField.frame), textFieldWidth, 44)];
    passField.placeholder=@"建议数字,字母符号组合";
    passField.font=[UIFont systemFontOfSize:17];
    UIImageView *mima = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mima"]];
    passField.leftView=mima;
    passField.leftViewMode=UITextFieldViewModeAlways;
    passField.delegate=self;
    passField.secureTextEntry=YES;
    passField.borderStyle=UITextFieldViewModeAlways;
    [self.view addSubview:passField];
    
    wordField=[[UITextField alloc]initWithFrame:CGRectMake(13, CGRectGetMaxY(passField.frame), textFieldWidth, 44)];
    wordField.placeholder=@"请确认密码";
    wordField.font=[UIFont systemFontOfSize:17];
    wordField.leftView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mima"]];
    wordField.leftViewMode=UITextFieldViewModeAlways;
    wordField.delegate=self;
    wordField.secureTextEntry=YES;
    wordField.borderStyle=UITextFieldViewModeAlways;
    [self.view addSubview:wordField];
    
    cityField=[[UITextField alloc]initWithFrame:CGRectMake(13, CGRectGetMaxY(wordField.frame), textFieldWidth, 44)];
    cityField.placeholder=@"请选择所在城市";
    cityField.font=[UIFont systemFontOfSize:17];
    UIImageView *city = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"suozaiweizi"]];
    cityField.leftView=city;
    cityField.leftViewMode=UITextFieldViewModeAlways;
    cityField.delegate=self;
    cityField.borderStyle=UITextFieldViewModeAlways;
    [self.view addSubview:cityField];

    
    check= [UIButton buttonWithType:UIButtonTypeCustom];
    check.frame=CGRectMake(15, CGRectGetMaxY(cityField.frame)+16, 44, 44);
    [check setImage:[UIImage imageNamed:@"weixuan"] forState:UIControlStateNormal];
    [check setImage:[UIImage imageNamed:@"yixuan"] forState:UIControlStateSelected];
    [check addTarget:self action:@selector(checkBtn) forControlEvents:UIControlEventTouchUpInside];
    check.selected=NO;
    [self.view addSubview:check];
    
    UILabel *read = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(check.frame)+5,  CGRectGetMaxY(cityField.frame)+16, 120, 44)];
    read.text=@"我已阅读并接受";
    read.textColor=[UIColor colorWithRed:118.0f/255.0f green:118.0f/255.0f blue:118.0f/255.0f alpha:1.0f];
    [self.view addSubview:read];
    
    UIButton *privacy = [UIButton buttonWithType:UIButtonTypeCustom];
    privacy.frame=CGRectMake(CGRectGetMaxX(read.frame),  CGRectGetMaxY(cityField.frame)+16, 80, 44);
    privacy.titleLabel.font=[UIFont systemFontOfSize:15];
    [privacy setTitle:@"“隐私条款”" forState:UIControlStateNormal];
    [privacy setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [privacy addTarget:self action:@selector(privacyPolicy) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:privacy];
    
    UIButton *registLogin = [UIButton buttonWithType:UIButtonTypeCustom];
    registLogin.frame=CGRectMake(20, CGRectGetMaxY(check.frame)+15, textFieldWidth, 50);
    registLogin.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"but"]];
    [registLogin setTitle:@"注册并登录" forState:UIControlStateNormal];
    [registLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registLogin addTarget:self action:@selector(RegistLoginBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registLogin];
    
    [self loadProvinceData];
}

#pragma mark -----------requestData
//请求城市数据
-(void)loadProvinceData
{
    [YHNetwork getInformationWithReguestType:RequestTypeGet WithParameters:nil WithApi:@"misc/province" WhenSuccess:^(NSMutableDictionary *response) {
        provinceArray = (NSArray *)response;  //用数组去接收数据
        
        [locationPickerView reloadComponent:0];
        [locationPickerView selectRow:0 inComponent:0 animated:YES];
        provinceName = provinceArray[0][@"name"];
        
    } WhenFailure:^(NSError *failure) {
        NSLog(@"%@",failure.localizedDescription);
    }];
}

//根据省份id请求城市信息
- (void)loadCityDataByProvinceID:(NSString*)provinceID
{
    [YHNetwork getInformationWithReguestType:RequestTypeGet WithParameters:@{@"provinceid":provinceID} WithApi:@"misc/city" WhenSuccess:^(NSMutableDictionary *response) {
        cityArray = response;
        [locationPickerView reloadComponent:1];
        [locationPickerView selectRow:0 inComponent:1 animated:YES];
        if (cityArray != nil && cityArray.count > 0) {
            cityName = cityArray[0][@"value"];
        }else{
            cityName = @"";
        }
        cityField.text = [NSString stringWithFormat:@"%@ %@",provinceName,cityName];
    } WhenFailure:^(NSError *failure) {
        NSLog(@"%@",failure.localizedDescription);
    }];
}

#pragma mark -----------loadView
//PickerView
-(void)setPickerView
{
    if (pickerVC == nil) {
        pickerVC = [[UIView alloc]initWithFrame:CGRectMake(13, CGRectGetMaxY(cityField.frame), textFieldWidth, 200)];
        pickerVC.backgroundColor=[UIColor whiteColor];
        [self.view addSubview:pickerVC];
   
        //plist文件读取
//        provinceDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"Provinces" ofType:@"plist"]];
//        
//        cityDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:provinceDict.allValues[0] ofType:@"plist"]];
        
        
        locationPickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0, 50,textFieldWidth, 150)];
//        locationPickerView.backgroundColor=[UIColor greenColor];
        locationPickerView.delegate=self;
        locationPickerView.dataSource=self;
        //显示选中框
        locationPickerView.showsSelectionIndicator=YES;
        locationPickerView.userInteractionEnabled=YES;
        [pickerVC addSubview:locationPickerView];
        
        
//  网络请求
        [locationPickerView reloadComponent:0];
        [locationPickerView selectRow:0 inComponent:0 animated:YES];
        
        //判断省份数组是否有元素,防止数组越界
        if (provinceArray == nil && provinceArray.count > 0) {
            provinceName = provinceArray[0][@"name"];
            [self loadCityDataByProvinceID:provinceArray[0][@"id"]];
        }
        
        
        
        //添加按钮
        UIButton *selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        selectBtn.frame=CGRectMake(0, 0, 100, 50);
        [selectBtn setTitle:@"确定" forState:UIControlStateNormal];
        [selectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [selectBtn addTarget:self action:@selector(selectButton) forControlEvents:UIControlEventTouchUpInside];
//        selectBtn.backgroundColor=[UIColor purpleColor];
        [pickerVC addSubview:selectBtn];
        
        UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        cancelBtn.frame=CGRectMake(textFieldWidth-100, 0, 100, 50);
        [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [cancelBtn addTarget:self action:@selector(cancelButton) forControlEvents:UIControlEventTouchUpInside];
//        cancelBtn.backgroundColor=[UIColor blackColor];
        [pickerVC addSubview:cancelBtn];
    }
}


#pragma mark  -----------action
//返回登录界面
-(void)backLogin
{
    //[self dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
    
}


//检查隐私条款
-(void)checkBtn
{
    check.selected = !check.selected;
}


//隐私条款
-(void)privacyPolicy
{
    PrivacyPolicyViewController * privacypolicyVC=[[PrivacyPolicyViewController alloc]init];
    [self presentViewController:privacypolicyVC animated:YES completion:nil];
    
//    [self.navigationController pushViewController:privacypolicyVC animated:YES];
}

//注册信息提示
-(void)alertView
{
    alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alertView show];

}

#pragma mark  -----------------request
//注册登录     //接口%@/user/signup     http://cent.dsgrd.com/user/signup
-(void)RegistLoginBtn
{
    NSLog(@"-----");
//    NSLog(@"%@",[(UITextField*)[self.view viewWithTag:100] text]);

    if ([userField.text isEqualToString:@""]) {
        [self alertView];
        alertView.message=@"请输入用户名";
    }else
//        if ([RegistViewController validateName:userField.text]==NO) {
//            [self alertView];
//            alertView.message=@"用户名6-18位,英文字母开头,必须包含数字和字母或下划线";
//        }else
            if (userField.text.length<6 || userField.text.length >18) {
                [self alertView];
                alertView.message=@"用户名6-18位,英文字母开头,必须包含数字和字母或下划线";
            }else
        if ([iphoneField.text isEqualToString:@""]) {
            [self alertView];
            alertView.message=@"手机号不能为空";
        }else
            if ([RegistViewController validateMobile:iphoneField.text]==NO) {
                [self alertView];
                alertView.message=@"请输入正确的手机号码";
            }else
               if ([passField.text isEqualToString:@""]) {
                [self alertView];
                alertView.message=@"密码不能为空";
             }else
                if ([wordField.text isEqualToString:@""]) {
                    [self alertView];
                    alertView.message=@"请再次输入密码";
                }else
                    if (![passField.text isEqualToString:wordField.text]) {
                        [self alertView];
                       alertView.message=@"两次密码不一致,请重新输入";
                    }else
                        if ( passField.text.length <6 || passField.text.length >16) {
                            [self alertView];
                            alertView.message=@"密码长度为6-16位";
                        }else
                       if ([cityField.text isEqualToString:@""]) {
                        [self alertView];
                        alertView.message=@"请填写您所在的城市信息";
                    }else
                        if (check.selected==NO) {
                            [self alertView];
                            alertView.message=@"请先阅读并同意隐私条款";
                        }else {
                            NSMutableDictionary *parems = [NSMutableDictionary dictionary];
                            parems[@"username"] = userField.text;
                            parems[@"password"] = passField.text;
                            parems[@"mobile"] = iphoneField.text;
                            parems[@"area1"] = provinceName;
                            parems[@"area2"] = cityName;
                            
                            [YHNetwork getInformationWithReguestType:RequestTypePost WithParameters:parems WithApi:@"user/signup" WhenSuccess:^(NSMutableDictionary *response) {
                                NSLog(@"%@",response);
                                rDict = response;
                                [self requestRegistData];
                                NSLog(@"%@",rDict[@"data"][@"username"]);//解析数据
                            } WhenFailure:^(NSError *failure) {
                                NSLog(@"%@",failure.localizedDescription);
                            }];
                        }
    
}

-(void)requestRegistData
{
    int i = [rDict[@"code"]intValue];
    if (i == 0) {
        NSLog(@"注册成功");
        PersonalViewController *personalVC = [[PersonalViewController alloc]init];
        //[self.navigationController pushViewController:personalVC animated:YES];
        [self presentViewController:personalVC animated:YES completion:nil];
        
        NSLog(@"%@",self.navigationController);
        
        //循环替换为空字符串
        newDict = [NSMutableDictionary dictionaryWithDictionary:rDict[@"data"]];
        for (NSString *key in newDict.allKeys) {
            if ([newDict[key] isKindOfClass:[NSNull class]]) {
                newDict[key] = @"";
            }
        }
        
        [[NSUserDefaults standardUserDefaults]setObject:@"yes" forKey:@"regist"];
        
        //保存数据
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"access_token"] forKey:kAccessToken];
        
//        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"area1"] forKey:@"area1"];
//        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"area2"] forKey:@"area2"];
        [[NSUserDefaults standardUserDefaults]setObject:[NSString stringWithFormat:@"%@ %@",newDict[@"area1"],newDict[@"area2"]] forKey:kAddress];
        
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"auth_key"] forKey:kAuthKey];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"avatar"] forKey:kAvatar];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"cellphone"] forKey:kMobile];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"created_at"] forKey:kRegisterDate];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"email"] forKey:kEmail];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"id"] forKey:kID];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"last_login_ip"] forKey:kLastLoginIP];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"link_data"][@"webid"] forKey:@"webid"];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"nickname"] forKey:kNickName];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"role"] forKey:kRole];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"source"] forKey:kSource];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"updated_at"] forKey:kUpdatedat];
        [[NSUserDefaults standardUserDefaults]setObject:newDict[@"username"] forKey:kUserName];
        [[NSUserDefaults standardUserDefaults]synchronize];
        
        
        //数据
        NSLog(@"%@",newDict[@"access_token"]);           //token
        NSLog(@"%@",newDict[@"area1"]);                  //省份
        NSLog(@"%@",newDict[@"area2"]);                  //城市
        NSLog(@"%@",newDict[@"auth_key"]);               //空
        NSLog(@"%@",newDict[@"avatar"]);                 //空字符串
        NSLog(@"%@",newDict[@"cellphone"]);              //电话
        NSLog(@"%@",newDict[@"created_at"]);             //
        NSLog(@"%@",newDict[@"email"]);                  //
        NSLog(@"%@",newDict[@"id"]);                     //
        NSLog(@"%@",newDict[@"last_login_ip"]);          //
        NSLog(@"%@",newDict[@"last_login_time"]);        //
        NSLog(@"%@",newDict[@"link_data"][@"webid"]);    //
        NSLog(@"%@",newDict[@"nickname"]);               //
        NSLog(@"%@",newDict[@"role"]);                   //
        NSLog(@"%@",newDict[@"source"]);                 //
        NSLog(@"%@",newDict[@"updated_at"]);             //
        NSLog(@"%@",newDict[@"username"]);               //用户名
        
        //[[NSNotificationCenter defaultCenter]postNotificationName:@"registsuccess" object:personalVC];
        //[self dismissViewControllerAnimated:YES completion:^{
            
            
                        //[self.drawer replaceCenterViewControllerWithViewController:personalVC];
            
        //}];
    
        
    }else if(i == 1)
    {
        NSString *message = @"";
        for (NSString *key in [rDict[@"data"] allKeys]) {
            message = [[message stringByAppendingString:rDict[@"data"][key]] stringByAppendingString:@"\n"];
        }

        UIAlertView *_alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [_alertView show];
        [[NSUserDefaults standardUserDefaults]setObject:@"no" forKey:@"regist"];
    }
}


//判断用户名
+ (BOOL)validateName:(NSString*)name
{
//    NSString* nameRegex=@"^[A-Za-z0-9]+$";
    
    NSString* nameRegex=@"^[A-Za-z]+[A-Za-z0-9]$";
//    NSString* nameRegex=@"^[a-zA-Z]\w{5,17}$";
    NSPredicate *nameTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",nameRegex];
    return [nameTest evaluateWithObject:name];
    
    
}

//判断手机号码
+(BOOL)validateMobile:(NSString*)mobile
{
    //NSString* phoneRegex=@"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    NSString* phoneRegex=@"^(13|15|18)[0-9]{9}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:mobile];
}

//选中
-(void)selectButton
{
    NSLog(@"确定");
    
    //locationPickerView组建选中的行号
//    NSInteger provinceIndex = [locationPickerView selectedRowInComponent:0];
//    NSInteger cityIndex = [locationPickerView selectedRowInComponent:1];
//    
//     NSLog(@"%@，%@",provinceDict.allKeys[provinceIndex],cityDict.allKeys[cityIndex]);
    
    [pickerVC removeFromSuperview];
    pickerVC = nil;
}

//取消
-(void)cancelButton
{
    NSLog(@"取消");
    [pickerVC removeFromSuperview];
    pickerVC = nil;
}


#pragma mark  ---------------UITextFieldDelegate
//textfield收键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    NSLog(@"------");
    [textField endEditing:YES];
    return YES;
}

//文本框要开始编辑        弹pickerVC
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField == cityField) {
        [self.view endEditing:YES];
        [self setPickerView];
        return NO;
    }
    return YES;
}

//文本框开始编辑          点击别的文本框收起pickerVC
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField != cityField) {
        [pickerVC removeFromSuperview];
        pickerVC = nil;
    }
}



#pragma mark  ---------------UIPickerViewDelegate
//返回显示的列数
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}

//返回当前显示的行数
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if (component == 0) {
        //return provinceDict.allKeys.count;
        return provinceArray.count;
    }
    //return cityDict.allKeys.count;
    return cityArray.count;
}

//返回当前行的内容
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (component == 0) {
//        return provinceDict.allKeys[row];
        NSDictionary *dict = provinceArray[row];
        return dict[@"name"];

    }
//    return [cityDict.allKeys objectAtIndex:row];
    return cityArray[row][@"value"];
}

//选中某一行
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
   if (component == 0) {
       //plist
//        NSString *fileName = provinceDict.allValues[row];
//        cityDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:fileName ofType:@"plist"]];
//        
//        //让城市列表默认选中第一列
//        [pickerView selectRow:0 inComponent:1 animated:YES];
//        [pickerView reloadComponent:1];
//        provinceName = provinceDict.allKeys[row];
//        if (cityDict.allKeys.count > 0) {
//            cityName = cityDict.allKeys[0];
//        }else{
//            cityName = @"";
//        }
//    }else{
//        cityName = cityDict.allKeys[row];
//    }
       
       
       [self loadCityDataByProvinceID:provinceArray[row][@"id"]];
       provinceName = provinceArray[row][@"name"];
   }else{
       cityName = cityArray[row][@"value"];
   }
    
        cityField.text = [NSString stringWithFormat:@"%@ %@",provinceName,cityName];
    
    
    
}

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
    [pickerVC removeFromSuperview];
    pickerVC = nil;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
